package com.homework.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.homework.entity.Homework;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface HomeworkMapper extends BaseMapper<Homework> {

    /**
     * 查询指定时间范围内与给定作业时间冲突的作业列表
     */
    List<Homework> findConflictingHomework(
            @Param("studentId") Long studentId,
            @Param("startTime") LocalDateTime startTime,
            @Param("endTime") LocalDateTime endTime,
            @Param("excludeId") Long excludeId
    );

    /**
     * 查询当前时间应该显示的作业（最早的）
     */
    Homework findCurrentHomework(@Param("studentId") Long studentId, @Param("currentTime") LocalDateTime currentTime);

    /**
     * 查询所有当前时间应该显示的作业
     */
    List<Homework> findAllCurrentHomework(@Param("studentId") Long studentId, @Param("currentTime") LocalDateTime currentTime);

    /**
     * 查询指定日期的作业记录
     */
    List<Homework> findHomeworkByDate(@Param("studentId") Long studentId, @Param("date") LocalDateTime date);
}